home *** CD-ROM | disk | FTP | other *** search
- /*
- Created: Tuesday, January 23, 1990 at 11:44 AM
- Updated: Thursday, June 14, 1990 1:37:30 PM
-
- Sound.h
- Pascal Interface to the Macintosh Libraries
-
- Contains: additions to sound header files for multiple channels, sound input, channel status reporting
-
- Written by: Neil Cormia, Hugh Svendsen, Michael Bartlow
-
- Copyright: © 1988-1990 by Apple Computer, Inc., all rights reserved.
-
- */
- /*EASE$$$ WRITE PRIVILEGED COPY of file “Sound.h”
-
-
-
- /*EASE$$$ VERSION: 1.2
- /*EASE$$$ USER: Neil J. Cormia
- /*EASE$$$ DATE: 08/18/1989
- /*EASE$$$ COMMENT:
- ** 1.1 CCH 11/ 9/1988 Fixed headers and removed projector resource.
- ** 1.0 CCH 11/ 9/1988 Adding to EASE.
- ** END EASE MODIFICATION HISTORY */
-
- /************************************************************
-
- Created: Wednesday, October 26, 1988 at 11:49 PM
- Sound.h
- C Interface to the Macintosh Libraries
-
-
- Copyright Apple Computer, Inc. 1986-1988
- All rights reserved
-
- ************************************************************/
-
-
- #ifndef __SOUND__
- #define __SOUND__
-
- #ifdef applec
- #ifndef __TYPES__
- #include <Types.h>
- #endif
- #else
- typedef double extended;
- #endif
-
- #define synthCodeRsrc 'snth'
- #define soundListRsrc 'snd '
-
- /* synthesizer numbers for SndNewChannel */
-
- #define noteSynth 1 /*note synthesizer*/
- #define waveTableSynth 3 /*wave table synthesizer*/
- #define sampledSynth 5 /*sampled sound synthesizer*/
-
- /* Param2 values */
-
- #define twelthRootTwo 1.05946309434
- #define infiniteTime 0x7FFFFFFF
-
- /* command numbers for SndDoCommand */
-
- #define nullCmd 0
- #define initCmd 1
- #define freeCmd 2
- #define quietCmd 3
- #define flushCmd 4
- #define reInitCmd 5
-
- #define waitCmd 10
- #define pauseCmd 11
- #define resumeCmd 12
- #define callBackCmd 13
- #define syncCmd 14
- #define emptyCmd 15
-
- #define tickleCmd 20
- #define requestNextCmd 21
- #define howOftenCmd 22
- #define wakeUpCmd 23
- #define availableCmd 24
- #define versionCmd 25
- #define totalLoadCmd 26
- #define loadCmd 27
-
- #define scaleCmd 30
- #define tempoCmd 31
-
- #define noteCmd 40
- #define restCmd 41
- #define freqCmd 42
- #define ampCmd 43
- #define timbreCmd 44
-
- #define waveTableCmd 60
- #define phaseCmd 61
-
- #define soundCmd 80
- #define bufferCmd 81
- #define rateCmd 82
- #define continueCmd 83
- #define doubleBufferCmd 84
- #define getRateCmd 85
-
- #define sizeCmd 90
- #define convertCmd 91
-
- #define stdQLength 128
- #define dataPointerFlag 0x8000
-
- #define waveInitChannelMask 0x07
- #define waveInitChannel0 0x04
- #define waveInitChannel1 0x05
- #define waveInitChannel2 0x06
- #define waveInitChannel3 0x07
-
- #define initSRateMask 0x0030
- #define initStereoMask 0x00C0
- #define initChanLeft 0x0002 /*left stereo channel */
- #define initChanRight 0x0003 /*right stereo channel*/
- #define initSRate22k 0x0020 /*22k sampling rate*/
- #define initMono 0x0080 /*monophonic channel*/
- #define initStereo 0x00C0 /*stereo channel*/
- #define initNoInterp 0x0004 /*no Linear Interpolation with the SR Convert*/
- #define initNoSRC 0x0008
- #define initNoMultiChannel 0x1000
- #define initMACE3 0x0300
- #define initMACE6 0x0400
-
- #define stdSH 0x00
- #define extSH 0xFF
- #define cmpSH 0xFE
- #define notCompressed 0
- #define twoToOne 1
- #define eightToThree 2
- #define threeToOne 3
- #define sixToOne 4
- #define outsideCmpSH 0
- #define insideCmpSH 1
- #define aceSuccess 0
- #define aceMemFull 1
- #define aceNilBlock 2
- #define aceBadComp 3
- #define aceBadEncode 4
- #define aceBadDest 5
- #define aceBadCmd 6
- #define sixToOnePacketSize 8
- #define threeToOnePacketSize 16
- #define stateBlockSize 64
- #define leftOverBlockSize 32
-
- #define firstSoundFormat 0x0001 /* general sound format */
- #define secondSoundFormat 0x0002 /* special sampled sound format */
-
-
- /*typedef long Time; in half milliseconds */
-
- typedef unsigned char Wave[256];
- typedef Wave *WavePtr;
-
-
- #define sysBeepDisable 0x0000
- #define sysBeepEnable 0x0001
-
- /* unitTypes for AudioSelection.unitType */
- #define unitTypeNoSelection 0xFFFF
- #define unitTypeSeconds 0x0000
-
-
- #define dbBufferEmpty 0x00000000 /* Constants for SndPlayDoubleBuffer*/
- #define dbBufferEmptyMask 0xFFFFFFFE
- #define dbBufferReady 0x00000001
- #define dbBufferExhausted 0x00000002
- #define dbLastBuffer 0x00000004
-
-
- /*••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••*/
- /*
- /* Error Codes for Sound Manager and Sound Manager 7.0
- /*
- /*••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••*/
-
-
- #define notEnoughBufferSpace -207 /* could not allocate enough memory */
- #define badFileFormat -208 /* was not type AIFF or was of bad format,corrupt */
- #define channelBusy -209 /* the Channel is being used for a PFD already */
- #define buffersTooSmall -210 /* can not operate in the memory allowed */
- #define channelNotBusy -211
- #define noMoreRealTime -212 /* not enought CPU cycles left to add another task */
- #define badParam -213 /* invalid argument */
-
- /*••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••*/
- /*
- /* Structures for Sound Driver
- /*
- /*••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••*/
-
- typedef unsigned char FreeWave[30001];
-
- struct FFSynthRec {
- short mode;
- Fixed count;
- FreeWave waveBytes;
- };
-
- typedef struct FFSynthRec FFSynthRec;
- typedef FFSynthRec *FFSynthPtr;
-
- struct Tone {
- short count;
- short amplitude;
- short duration;
- };
-
- typedef struct Tone Tone;
- typedef Tone Tones[5001];
-
- struct SWSynthRec {
- short mode;
- Tones triplets;
- };
-
- typedef struct SWSynthRec SWSynthRec;
- typedef SWSynthRec *SWSynthPtr;
-
- struct FTSoundRec {
- short duration;
- Fixed sound1Rate;
- long sound1Phase;
- Fixed sound2Rate;
- long sound2Phase;
- Fixed sound3Rate;
- long sound3Phase;
- Fixed sound4Rate;
- long sound4Phase;
- WavePtr sound1Wave;
- WavePtr sound2Wave;
- WavePtr sound3Wave;
- WavePtr sound4Wave;
- };
-
- typedef struct FTSoundRec FTSoundRec;
- typedef FTSoundRec *FTSndRecPtr;
-
- struct FTSynthRec {
- short mode;
- FTSndRecPtr sndRec;
- };
-
- typedef struct FTSynthRec FTSynthRec;
- typedef FTSynthRec *FTSynthPtr;
-
-
- /*••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••*/
- /*
- /* Structures for Sound Manager
- /*
- /*••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••*/
-
-
- typedef struct SndCommand {
- unsigned short cmd;
- short param1;
- long param2;
- }SndCommand;
-
-
- typedef struct SndChannel *SndChannelPtr;
- typedef /*pascal*/ void (*SndCompletionProcPtr)(void);
- typedef /*pascal*/ Boolean (*SndCallBackProcPtr)(struct SndChannel *chan, SndCommand cmd);
- typedef ProcPtr SndModifierProcPtr;
-
-
-
- typedef struct SoundHeader
- {
- char * samplePtr; /* if NIL then samples are in sampleArea */
- unsigned long length;
- Fixed sampleRate;
- unsigned long loopStart,
- loopEnd;
- unsigned char encode; /* <hbs 12/20/88> header type */
- unsigned char baseNote; /* <hbs 12/20/88> basenote now byte */
- char sampleArea[/*0*/];
- } SoundHeader, *SoundHeaderPtr;
-
-
- typedef struct SndChannel {
- SndChannelPtr nextChan;
- Ptr firstMod;
- SndCallBackProcPtr callBack;
- long userInfo;
- long wait; /* The following is for internal Sound Manager use only.*/
- SndCommand cmdInProgress;
- short flags;
- short qLength;
- short qHead; /* next spot to read or -1 if empty */
- short qTail; /* next spot to write = qHead if full */
- SndCommand queue[128];
- } SndChannel;
-
-
- typedef struct ModifierStub {
- struct ModifierStub *nextStub;
- SndModifierProcPtr code;
- long userInfo;
- /*Time*/long count;
- /*Time*/long every;
- char flags;
- char hState;
- } ModifierStub;
-
-
-
- /*______________________ <hbs 1/10/89> structs for mace____________________________ */
-
-
- typedef struct{
- short stateVar[stateBlockSize] ;
- } StateBlock, *StateBlockPtr;
-
-
- typedef struct
- {
- unsigned long count;
- char sampleArea[leftOverBlockSize];
- }
- LeftOverBlock, *LeftOverBlockPtr;
-
-
- typedef struct
- {
- char *samplePtr; /* if nil then samples are in sample area */
- unsigned long numChannels; /* CAFF, number of channels mono = 1 */
- Fixed sampleRate; /* sample rate in Apples Fixed point representation */
- unsigned long loopStart; /* loopStart of sound before compression */
- unsigned long loopEnd; /* loopEnd of sound before compression */
- unsigned char encode; /* data structure used , stdSH, extSH, or cmpSH */
- unsigned char baseNote; /* same meaning as regular SoundHeader */
- unsigned long numFrames; /* length in frames ( packetFrames or sampleFrames */
- extended AIFFSampleRate; /* CAFF, IEEE sample rate */
- Ptr MarkerChunk; /* CAFF, sync track */
- Ptr FutureUse1; /* reserved by Apple */
- Ptr FutureUse2; /* reserved by Apple */
- StateBlockPtr StateVars; /* pointer to State Block */
- LeftOverBlockPtr LeftOverSamples; /* used to save truncated samples between compression calls */
- unsigned short compressionID; /* 0 means no compression, non zero means compressionID */
- unsigned short packetSize; /* CAFF, number of bits in compressed sample packet */
- unsigned short snthID; /* Resource ID of Sound Manager snth that contains NRT C/E */
- unsigned short sampleSize; /* CAFF, number of bits in non-compressed sample */
- char sampleArea[/*0*/]; /* space for when samples follow directly */
- }
- CmpSoundHeader, *CmpSoundHeaderPtr;
-
- typedef struct
- {
- char *samplePtr; /* if nil then samples are in sample area */
- unsigned long numChannels; /* AIFF, number of channels, ie mono = 1 */
- Fixed sampleRate; /* sample rate in Apples Fixed point representation */
- unsigned long loopStart; /* same meaning as regular SoundHeader */
- unsigned long loopEnd; /* same meaning as regular SoundHeader */
- unsigned char encode; /* data structure used , stdSH, extSH, or cmpSH */
- unsigned char baseNote; /* same meaning as regular SoundHeader */
- unsigned long numSampleFrames; /* length in total number of frames */
- extended AIFFSampleRate; /* AIFF, IEEE sample rate */
- Ptr MarkerChunk; /* AIFF, sync track */
- Ptr InstrumentChunks; /* AIFF, */
- Ptr AESRecording; /* AIFF, */
- unsigned short sampleSize; /* AIFF, number of bits in sample */
- unsigned short FutureUse1; /* reserved by Apple */
- unsigned long FutureUse2; /* reserved by Apple */
- unsigned long FutureUse3; /* reserved by Apple */
- unsigned long FutureUse4; /* reserved by Apple */
- char sampleArea[/*0*/]; /* space for when samples follow directly */
- }
- ExtSoundHeader, *ExtSoundHeaderPtr;
-
-
-
- typedef struct{
- short smMaxCPULoad;
- short smNumChannels;
- short smCurCPULoad;
- }
- SMStatus, *SMStatusPtr;
-
-
- typedef struct{
- Fixed scStartTime;
- Fixed scEndTime;
- Fixed scCurrentTime;
- Boolean scChannelBusy;
- Boolean scChannelDisposed;
- Boolean scChannelPaused;
- char scUnused;
- unsigned long scChannelAttributes;
- long scCPULoad;
- }
- SCStatus,*SCStatusPtr;
-
-
- typedef struct {
- long dbNumFrames;
- long dbFlags;
- long dbUserInfo[2];
- char dbSoundData[/*0*/];
- } SndDoubleBuffer, *SndDoubleBufferPtr;
-
-
- typedef struct{
- long unitType;
- Fixed selStart;
- Fixed selEnd;
- }AudioSelection, *AudioSelectionPtr;
-
-
- typedef struct {
- short dbhNumChannels;
- short dbhSampleSize;
- short dbhCompressionID;
- short dbhPacketSize;
- Fixed dbhSampleRate;
- SndDoubleBufferPtr dbhBufferPtr[2];
- ProcPtr dbhDoubleBack;
- }
- SndDoubleBufferHeader, *SndDoubleBufferHeaderPtr;
-
- typedef struct ModRef {
- unsigned short modNumber;
- long modInit;
- } ModRef;
-
-
- typedef struct SndListResource {
- short format;
- short numModifiers;
- ModRef modifierPart[1]; /*This is a variable length array*/
- short numCommands;
- SndCommand commandPart[1]; /*This is a variable length array*/
- char dataPart[1]; /*This is a variable length array*/
- } SndListResource, *SndListPtr;
-
-
- pascal OSErr SndDoCommand(SndChannelPtr chan,/*??const*/ SndCommand *cmd,Boolean noWait)
- = 0xA803;
- pascal OSErr SndDoImmediate(SndChannelPtr chan,/*??const*/ SndCommand *cmd)
- = 0xA804;
- pascal OSErr SndNewChannel(SndChannelPtr *chan,short synth,long init,SndCallBackProcPtr userRoutine)
- = 0xA807;
- pascal OSErr SndDisposeChannel(SndChannelPtr chan,Boolean quietNow)
- = 0xA801;
- pascal OSErr SndPlay(SndChannelPtr chan,Handle sndHdl,Boolean async)
- = 0xA805;
- pascal OSErr SndControl(short id,SndCommand *cmd)
- = 0xA806;
-
-
- /*••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••*/
- /*
- /* New Enhanced Sound Manager 7.0 Calls <18 Aug 1989 NJC>
- /*
- /* These will soon be supported by a Glue Library so that all this ugly
- /* shit will disappear and the traps will look like non-indexed traps.
- /*
- /*••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••*/
-
- #define MOVEL 0x203C
-
- /* constants for MACE in the dispatcher */
- #define MACEToolNum 16
- #define sMgrMACEVersion 0
- #define sMgrComp3to1 4
- #define sMgrExp1to3 8
- #define sMgrComp6to1 12
- #define sMgrExp1to6 16
-
- /* constants for Sound Manager Extensions in the dispatcher */
- #define sMgrToolNum 8
- #define sMgrSndStartFilePlay 3328 /* (13*256)+0 */
- #define sMgrSndPauseFilePlay 516 /* (2*256)+4 */
- #define sMgrSndStopFilePlay 776 /* (3*256)+8 */
- #define sMgrSndSoundManagerVersion 12
- #define sMgrSndChannelStatus 16
- #define sMgrSndManagerStatus 20
- #define sMgrSndGetSysBeepState 24
- #define sMgrSndSetSysBeepState 28
- #define sMgrSndPlayDoubleBuffer 32
- #define sMgrSndGetBufferStufferLoad 36
- #define sMgrSndGetMixerLoad 40
-
- pascal unsigned long
- SndSoundManagerVersion (void)
- = {MOVEL,sMgrSndSoundManagerVersion,sMgrToolNum,0xA800};
-
- pascal OSErr
- SndStartFilePlay ( SndChannelPtr theChannel, short fRefNum,
- short resNum, long bufferSize, Ptr bufferPtr,
- AudioSelectionPtr theSelection, ProcPtr theCompletion, Boolean async)
- = {MOVEL,sMgrSndStartFilePlay,sMgrToolNum,0xA800};
-
- pascal OSErr
- SndPauseFilePlay (SndChannelPtr theChannel)
- = {MOVEL,sMgrSndPauseFilePlay,sMgrToolNum,0xA800};
-
- pascal OSErr
- SndStopFilePlay (SndChannelPtr theChannel, Boolean noWait)
- = {MOVEL,sMgrSndStopFilePlay,sMgrToolNum,0xA800};
-
- pascal OSErr
- SndChannelStatus (SndChannelPtr theChannel,
- short theLength, SCStatusPtr theStatus)
- = {MOVEL,sMgrSndChannelStatus,sMgrToolNum,0xA800};
-
- pascal OSErr
- SndManagerStatus (short theLength, SMStatusPtr theStatus)
- = {MOVEL,sMgrSndManagerStatus,sMgrToolNum,0xA800};
-
- pascal void
- SndGetSysBeepState ( short *sysBeepState)
- = {MOVEL,sMgrSndGetSysBeepState,sMgrToolNum,0xA800};
-
- pascal OSErr
- SndSetSysBeepState (short sysBeepState)
- = {MOVEL,sMgrSndSetSysBeepState,sMgrToolNum,0xA800};
-
- pascal OSErr
- SndPlayDoubleBuffer ( SndChannelPtr theChannel, SndDoubleBufferHeaderPtr theParams)
- = {MOVEL,sMgrSndPlayDoubleBuffer,sMgrToolNum,0xA800};
-
- pascal short
- SndGetBufferStufferLoad (short channelFeatures)
- = {MOVEL,sMgrSndGetBufferStufferLoad,sMgrToolNum,0xA800};
-
- pascal short
- SndGetMixerLoad (short numChannels)
- = {MOVEL,sMgrSndGetMixerLoad,sMgrToolNum,0xA800};
-
- pascal unsigned long
- MACEVersion ()
- = {MOVEL,sMgrMACEVersion,MACEToolNum,0xA800};
-
- pascal void Comp3to1 ( Ptr inBuffer, Ptr outBuffer, unsigned long Cnt, Ptr inState,
- Ptr outState, unsigned long numChannels, unsigned long whichChannel )
- = {MOVEL,sMgrComp3to1,MACEToolNum,0xA800};
-
- pascal void Exp1to3 ( Ptr inBuffer, Ptr outBuffer, unsigned long Cnt, Ptr inState,
- Ptr outState, unsigned long numChannels, unsigned long whichChannel)
- = {MOVEL,sMgrExp1to3,MACEToolNum,0xA800};
-
- pascal void Comp6to1 ( Ptr inBuffer, Ptr outBuffer, unsigned long Cnt, Ptr inState,
- Ptr outState, unsigned long numChannels, unsigned long whichChannel )
- = {MOVEL,sMgrComp6to1,MACEToolNum,0xA800};
-
- pascal void Exp1to6 ( Ptr inBuffer, Ptr outBuffer, unsigned long Cnt, Ptr inState,
- Ptr outState, unsigned long numChannels, unsigned long whichChannel)
- = {MOVEL,sMgrExp1to6,MACEToolNum,0xA800};
-
-
- pascal void SetSoundVol(short level);
- pascal void GetSoundVol(short *level);
- pascal void StartSound(Ptr synthRec,long numBytes,SndCompletionProcPtr completionRtn);
- pascal void StopSound(void);
- pascal Boolean SoundDone(void);
- pascal OSErr SndAddModifier(SndChannelPtr chan,SndModifierProcPtr modifier,
- short id,long init)
- = 0xA802;
-
-
- #endif